#include<bits/stdc++.h>
#define LL long long
using namespace std;
int T,n,m,L,V,cnt1,cnt2;
int d[100001],v[100001],a[100001],p[100001],z[100001],v_[100001];
bool flagA,flagB,flagC;
void init() {
    flagA=flagB=flagC=1;
    cnt1=cnt2=0;
    for(int i=1;i<=n;i++) {
        d[i]=v[i]=a[i]=p[i]=z[i]=v_[i]=0;
    }
    return ;
}
int calc(int idx) {
    return (v[idx]*v[idx]+2*a[idx]*(p[m]-d[idx]));
}
int main() {
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>T;
    while(T--) {
        cin>>n>>m>>L>>V;
        init();
        for(int i=1;i<=n;i++) {
            cin>>d[i]>>v[i]>>a[i];
            if(a[i]) {
                flagA=0;
            }
            if(a[i]<0) {
                flagB=0;
            }
            if(a[i]>0) {
                flagC=0;
            }
        }
        for(int i=1;i<=m;i++) {
            cin>>p[i];
        }
        sort(p+1,p+1+m);
        if(flagA) {
            for(int i=1;i<=n;i++) {
                if(d[i]<=p[m] && v[i]>V) {
                    cnt1++;
                }
            }
            cout<<cnt1<<' '<<m-1<<'\n';
        } else if(flagB) {
            for(int i=1;i<=n;i++) {
                if(d[i]>p[m]) continue;
                double X=calc(i);
                double Y=V*V;
                if(X>Y) {
                    cnt1++;
                }
            }
            cout<<cnt1<<' '<<m-1<<'\n';
        }
    }

    return 0;
}